from django.contrib.auth.models import AbstractUser,UserManager as _UserManager
from django.db import models

# Create your models here.
class UserManager(_UserManager):
    def create_superuser(self, username, password, email=None, **extra_fields):
        return super().create_superuser(username=username, password=password, email=email, **extra_fields)


class User(AbstractUser):
    mobile = models.CharField('手机号',max_length=11,unique=True,help_text='手机号', error_messages={'unique': '此手机号码已注册'})
    email_active = models.BooleanField('邮箱状态',default=False)
    class Meta:
        db_table = 'tb_user'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return  self.username

    objects = UserManager()
    REQUIRED_FIELDS = ['mobile']
